package com.minew.beaconset.broadcast;

import java.util.HashMap;
import java.util.Map;

/**
 * 宿主与插件通信协议
 */
public class BroadMessage {
    private boolean success = true;
    private String command;//指令
    private Map<String,Object> param = new HashMap<>();//参数
    private Object result;//结果集
    private String message;//提示消息
    private Object data;

    private String status;

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public static BroadMessage newBroadMessage(){
        return new BroadMessage();
    }

    public String getCommand() {
        return command;
    }

    public BroadMessage setCommand(String command) {
        this.command = command;
        return this;
    }

    public Map<String, Object> getParam() {
        return param;
    }

    public BroadMessage putParam(String key, Object value){
        param.put(key,value);
        return this;
    }
    public <T>T getParam(String key){
        if(param!=null&&key!=null){
            return (T)param.get(key);
        }
        return null;
    }
    public BroadMessage setParam(Map<String, Object> param) {
        this.param = param;
        return this;
    }

    public <T>T getResult() {
        return (T)result;
    }

    public BroadMessage setResult(Object result) {
        this.result = result;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public BroadMessage setMessage(String message) {
        this.message = message;
        return this;
    }

    public boolean isSuccess() {
        return success;
    }

    public BroadMessage setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public <T>T getData() {
        return (T)data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
